﻿find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTSPrint Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets PrintSupport)

# 查找 qtcsv
set(qtcsv_DIR D:/libraries/C++/Qt/qtcsv/share/qtcsv/cmake)
find_package(qtcsv REQUIRED)
# 查找 QXlsx
set(QXlsxQt${QT_VERSION_MAJOR}_DIR D:/libraries/C++/Qt/QXlsx/lib/cmake/QXlsxQt6)
find_package(QXlsxQt${QT_VERSION_MAJOR} REQUIRED)
include_directories(D:\\libraries\\C++\\Qt\\QXlsx\\include)
link_directories(D:\\libraries\\C++\\Qt\\QXlsx\\lib)
# 查找 qt${QT_VERSION_MAJOR}advanceddocking 
set(qt${QT_VERSION_MAJOR}advanceddocking_DIR D:/libraries/C++/Qt/QtADS/lib/cmake/qt6advanceddocking)
find_package(qt${QT_VERSION_MAJOR}advanceddocking REQUIRED)

file(GLOB_RECURSE SRC_FILE ./*.cpp ./*.h ./*.ui)
set(PROJECT_SOURCES
        ${SRC_FILE}
        ../images.qrc
        ../loge.rc
)
include_directories(.)
include_directories(./colorWidgets)
qt_add_executable(CurvePreviewRoom
    MANUAL_FINALIZATION
    ${PROJECT_SOURCES}
)

target_link_libraries(CurvePreviewRoom PRIVATE
    Qt${QT_VERSION_MAJOR}::Widgets
    ads::qt${QT_VERSION_MAJOR}advanceddocking
    Qt${QT_VERSION_MAJOR}::Gui
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::PrintSupport
    qtcsv
    QXlsxQt${QT_VERSION_MAJOR}
)
set_runtime_name(CurvePreviewRoom)
set_out_path(CurvePreviewRoom)
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.CurvePreviewRoom)
endif()
set_target_properties(CurvePreviewRoom PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
install(TARGETS CurvePreviewRoom
    BUNDLE DESTINATION .
    LIBRARY DESTINATION .
    RUNTIME DESTINATION .
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(CurvePreviewRoom)
endif()
